<template>
  <div>
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>系统管理</el-breadcrumb-item>
      <el-breadcrumb-item>参数设置</el-breadcrumb-item>
    </el-breadcrumb>

    <el-card>
 
   <el-row :gutter="20">
        <el-col :span="6">
            <el-label>急加速阈值设定</el-label>
        </el-col>
   </el-row>
   <el-row :gutter="20">
        <el-col :span="13">
            <el-label>加速度：[0，加速度1], (加速度1,加速度2], (加速度2,加速度3], (加速度3,加速度4], (加速度4,加速度5]</el-label>
        </el-col>

   </el-row>   
   <el-row :gutter="20">
        <el-col :span="13">
            <el-label>加速度：[0，{{acc1}}], ({{acc1}},{{acc2}}], ({{acc2}},{{acc3}}], ({{acc3}},{{acc4}}], ({{acc4}},{{acc5}}]</el-label>
        </el-col>

   </el-row>   

   <el-row :gutter="20">
        
            <el-col :span="1.5">
                <el-label>加速度1:</el-label>
            </el-col>
        <el-col :span="2">
             <el-input
            placeholder="加速度1"
            v-model="acc1"

          >
          </el-input>
        </el-col>
        <el-col :span="1">
            <el-label>&nbsp</el-label>   
        </el-col>

                    <el-col :span="1.5">
                <el-label>加速度2:</el-label>
            </el-col>
        <el-col :span="2">
             <el-input
            placeholder="加速度2"
            v-model="acc2"

          >
          </el-input>
        </el-col>
<el-col :span="1">
            <el-label>&nbsp</el-label>   
        </el-col>
                    <el-col :span="1.5">
                <el-label>加速度3:</el-label>
            </el-col>
        <el-col :span="2">
             <el-input
            placeholder="加速度3"
            v-model="acc3"

          >
          </el-input>
        </el-col>
<el-col :span="1">
            <el-label>&nbsp</el-label>   
        </el-col>
           <el-col :span="1.5">
                <el-label>加速度4:</el-label>
            </el-col>
        <el-col :span="2">
             <el-input
            placeholder="加速度4"
            v-model="acc4"

          >
          </el-input>
        </el-col>
<el-col :span="1">
            <el-label>&nbsp</el-label>   
        </el-col>
           <el-col :span="1.5">
                <el-label>加速度5:</el-label>
            </el-col>
        <el-col :span="2">
             <el-input
            placeholder="加速度5"
            v-model="acc5"

          >
          </el-input>
        </el-col>

      </el-row>

    <el-row :gutter="20">
        <el-col :span="2">
            <el-label>持续时间：</el-label> 
        </el-col>

         <el-col :span="1">
            <el-input
            placeholder="2"
            v-model="acclast"
          >
          </el-input>
          </el-col>

         <el-col :span="2">
          <el-label>S（秒）</el-label>
        </el-col>

        

   </el-row>    

<el-divider></el-divider>

    <el-row :gutter="20">
        <el-col :span="6">
            <el-label>急减速阈值设定</el-label>
        </el-col>
   </el-row>
   <el-row :gutter="20">
        <el-col :span="13">
            <el-label>减速度：[0，减速度1], (减速度1,减速度2], (减速度2,减速度3], (减速度3,减速度4], (减速度4,减速度5]</el-label>
        </el-col>

   </el-row>   
   <el-row :gutter="20">
        <el-col :span="13">
            <el-label>减速度：[0，{{nacc1}}], ({{nacc1}},{{nacc2}}], ({{nacc2}},{{nacc3}}], ({{nacc3}},{{nacc4}}], ({{nacc4}},{{nacc5}}]</el-label>
        </el-col>

   </el-row>   

   <el-row :gutter="20">
        
            <el-col :span="1.5">
                <el-label>减速度1:</el-label>
            </el-col>
        <el-col :span="2">
             <el-input
            placeholder="减速度1"
            v-model="nacc1"

          >
          </el-input>
        </el-col>
<el-col :span="1">
            <el-label>&nbsp</el-label>   
        </el-col>

                    <el-col :span="1.5">
                <el-label>减速度2:</el-label>
            </el-col>
        <el-col :span="2">
             <el-input
            placeholder="减速度2"
            v-model="nacc2"

          >
          </el-input>
        </el-col>
<el-col :span="1">
            <el-label>&nbsp</el-label>   
        </el-col>

                    <el-col :span="1.5">
                <el-label>减速度3:</el-label>
            </el-col>
        <el-col :span="2">
             <el-input
            placeholder="减速度3"
            v-model="nacc3"

          >
          </el-input>
        </el-col>

<el-col :span="1">
            <el-label>&nbsp</el-label>   
        </el-col>
           <el-col :span="1.5">
                <el-label>减速度4:</el-label>
            </el-col>
        <el-col :span="2">
             <el-input
            placeholder="减速度4"
            v-model="nacc4"

          >
          </el-input>
        </el-col>
<el-col :span="1">
            <el-label>&nbsp</el-label>   
        </el-col>
           <el-col :span="1.5">
                <el-label>减速度5:</el-label>
            </el-col>
        <el-col :span="2">
             <el-input
            placeholder="减速度5"
            v-model="nacc5"

          >
          </el-input>
        </el-col>

      </el-row>

    <el-row :gutter="20">
        <el-col :span="2">
            <el-label>持续时间：</el-label> 
        </el-col>

         <el-col :span="1">
            <el-input
            placeholder="2"
            v-model="nacclast"
          >
          </el-input>
          </el-col>

         <el-col :span="2">
          <el-label>S（秒）</el-label>
        </el-col>

        

   </el-row>    


        <el-row type="flex" justify="end">
            <el-button type="primary" @click="updateparam()" icon="el-icon-edit"
                        >确定修改</el-button>
            </el-row>
    </el-card>

  </div>
</template>

<script>

export default {
  data () {
    return {

      nowcontact: {},

      paramList: [],

      acc1:0,acc2:0,acc3:0,acc4:0,acc5:0,acclast:0,
      nacc1:0,nacc2:0,nacc3:0,nacc4:0,nacc5:0,nacclast:0


    }
  },
  created () {
    // 加载页面时 加载一次数据
    this.getparamList()
  },
  methods: {
  
  async getparamList () {
      const { data: res } = await this.$http.get('param/getparam/acc')
      if (res.code !== 200) return this.$message.error('Error:' + res.message)
      this.paramList = res.data
     // console.log(res.data)
      
      this.acc1 = this.paramList[0].value
      this.acc2 = this.paramList[1].value
      this.acc3 = this.paramList[2].value
      this.acc4 = this.paramList[3].value
      this.acc5 = this.paramList[4].value
      this.acclast = this.paramList[5].value

      this.nacc1 = this.paramList[6].value
      this.nacc2 = this.paramList[7].value
      this.nacc3 = this.paramList[8].value
      this.nacc4 = this.paramList[9].value
      this.nacc5 = this.paramList[10].value
      this.nacclast = this.paramList[11].value

    },

    async updateparam () {
      const { data: res } = await this.$http.post(
        'param/updateparam',
        { 
        'acc1': this.acc1, 
        'acc2': this.acc2, 
        'acc3': this.acc3, 
        'acc4': this.acc4, 
        'acc5': this.acc5, 
        'acclast':this.acclast,
        'nacc1': this.nacc1, 
        'nacc2': this.nacc2, 
        'nacc3': this.nacc3, 
        'nacc4': this.nacc4, 
        'nacc5': this.nacc5, 
        'nacclast':this.nacclast,

        }, {
          headers: {
            'content-type': 'application/json',
            'X-Request-With': 'XMLHttpRequest',
            'token': window.sessionStorage.getItem('token')
          }
        }
      )
      if (res.code !== 200) return this.$message.error('Error:' + res.message)
      this.getparamList()
    },



  },
  filters: {

  }
}
</script>

<style lang="less" scope>
.el-row {
    margin-bottom: 20px;
    &:last-child {
      margin-bottom: 0px;
      align:'center'
    }
  }

.el-label{
  align:'center'
}
</style>
